﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using Clipper.BLL.DetectChain;
using Clipper.BLL.Supplier;
using Clipper.DataManage;
using Clipper.Model;
using ClipperBaseUI.Controls;
using Global;
using Clipper.About;
using System.Windows.Media;
using System.Windows.Forms;
using Clipper.EngineerWindow;
using Communication;
using Clipper.ClipperUserControl;
using System.Threading;
using Clipper.ClipperWindow;
using log4net;
using Clipper.Model.Interface;
using Clipper.Model.DataBaseModel;

[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace Clipper
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window, RunClickEventClass
    {

        BLL.Reagent reagentBll = new BLL.Reagent();
        #region 变量
        //private NotifyIcon notifyIcon;
        int mOldMainTabItem = 0;
        int mOldEnginner = 0;
        BLL.SystemConfig mSysConfigBll = new BLL.SystemConfig();
        BLL.ResultReference mResultReferBll = new BLL.ResultReference();
        System.Timers.Timer WatchTimer;
        public delegate void TimerFunc();
        #endregion

        #region 初始化 No.2
        BLL.DataBaseBLL.LocaltionPosition localtionModel = new BLL.DataBaseBLL.LocaltionPosition();
        public MainWindow()
        {
            if (Height > SystemParameters.WorkArea.Height)
            {
                Height = SystemParameters.WorkArea.Height;
            }
            this.InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            //log4net.ILog log = log4net.LogManager.GetLogger("ErrorLog");
            //log.Error("日志测试");
            //cecshi! dongdong
            Global.ServiceProvider.CreateProvider();
            ServiceProvider.WaitMessage.CollectionChanged += new NotifyCollectionChangedEventHandler(WaitMessage_CollectionChanged);
            DetectChainHelper.Connect();           //连接仪器
            DetectChainHelper.RunRecieveData();    //开启接收数据线程
            DetectChainHelper.InitDetectChain();   //初始化反应链
            ServiceProvider.Monitor.MdcConfiger = ReadConfigerFile(); //加载配置文件
            DetectChainHelper.GetTemperature();    //获取各部分温度值         

            BackgroundWorker back = new BackgroundWorker();
            back.DoWork += (bss, bee) =>
            {
                //while (true)
                //{
                //    // 初始化操作执行的数据    No.2操作
                ArmMoveControl.InitArmMoveValue(localtionModel.GetModelList(""));

                //杯子复位
                DeliveryCupControl.AllReset();
                //简单清杯子
                DeliveryCupControl.AllResetCleanCup();
                //DeliveryCupControl.AllReset();
                //杯子初始化
                DeliveryCupControl.Init();
                //}
            };
            back.RunWorkerAsync();

            BackgroundWorker back1 = new BackgroundWorker();
            back1.DoWork += (bss, bee) =>
            {
                //while (true)
                //{
                //臂复位
                ArmMoveControl.ResetAllAxis();
                //臂初始化
                ArmMoveControl.Init(ArmMoveControl.clearDistance);
                //}
            };
            back1.RunWorkerAsync();


            //    userMonitor.DataBind();       //运行监视界面
            useWorkSheet1.DataBind();
            userReagentKit.DataBind();
            userDetectResult.DataBind();
            userQC.DataBind();
            userDetectReport.DataBind();
            userStandard.DataBind();
            mSysConfigBll.LoadConfig();
            this.DataContext = ServiceProvider.Monitor;

            userDisplayMonitor.DataBind();
            userDisplayResultToday.DataBind();  //动态绑定
            userDisplayResultMonitor.DataBind();


            ServiceProvider.Monitor.MResultReferenceList = mResultReferBll.GetFullDetectItemsInfoList("");

            //AddReagent1AndSample.PumpControl.Close();冲突

            //Can.SendCan(131, "NP121750" + Can.strEnd);
            //Can.SendCan(131, "NP021700" + Can.strEnd);


            //IncubationBox.IncubationControl.TemperatureSet(4400); //孵育箱温度设置
            WatchTimer = new System.Timers.Timer();
            WatchTimer.AutoReset = false;
            WatchTimer.Elapsed += new System.Timers.ElapsedEventHandler((ss, ee) =>
            {
                //if (ServiceProvider.VariableClass.PressButton.Equals("弹框"))
                //{
                //    WinTwiceNoRespone winTwice = new WinTwiceNoRespone();
                //    winTwice.Show();
                //}

                if (!ServiceProvider.Monitor.IsRunning) //判断是否处于 停止运行状态
                {
                    //且 按钮处于暂停状态
                    TimerFunc func = new TimerFunc(UpdateStatus);
                    Dispatcher.Invoke(func, new Object[] { });
                    WatchTimer.Close();
                }
                else
                {
                    WatchTimer.Start();
                }



            });
            WatchTimer.Interval = 500;
            // WatchTimer.Enabled = true;
            // WatchTimer.Start(); //开启时钟检测 启动 暂停状态

            //实例化接口类    
            CommonClass.WinDetect = new WinDetermineSampleLocation();
            CommonClass.WinDetect.instanceMain(this);

            ServiceProvider.pTISIValue = reagentBll.GetModelByReagentName("PT凝血酶").PtISIValue;//给默认值ISI

        }

        #endregion
        public void UpdateStatus()
        {
            if (btnRun.Header.ToString() == UIHelper.GetResourceText("Pause"))
            {
                btnRun.Header = UIHelper.GetResourceText("Run");
            }
            WinDetectEnd win = new WinDetectEnd();
            win.ShowDialog();
        }
        #region 按钮事件
        /// <summary>
        /// 关闭程序事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            Environment.Exit(0);
        }
        //打开数据管理
        private void DataMange_MouseUp(object sender, MouseButtonEventArgs e)
        {
            WinDataManage winDataManage = new WinDataManage();
            if (ServiceProvider.AdminValidate)
            {
                winDataManage.ShowDialog();
            }
            else
            {
                winPassword winPassword = new winPassword();
                winPassword.ShowDialog();
                if (ServiceProvider.AdminValidate)
                {
                    winDataManage.ShowDialog();
                }
            }

        }
        //主选项卡的切换
        private void BaseTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            if (baseTab.SelectedIndex == 7 || baseTab.SelectedIndex == 5 || baseTab.SelectedIndex == 0)
            {
                baseTab.SelectedIndex = mOldMainTabItem;
            }
            else
            {
                mOldMainTabItem = baseTab.SelectedIndex;
            }

            switch (baseTab.SelectedIndex)
            {
                case 2://运行监视
                    //userMonitor.DataBind();
                    break;
                case 3://工作列表
                    //useWorkSheet1.DataBind();
                    break;
                case 4://试剂设置
                    //userReagentKit.DataBind();
                    break;
                case 6://检测结果
                    //userDetectResult.DataBind();
                    //userStandard.DataBind();
                    break;
                case 8:

                    break;
            }
        }

        /// <summary>
        /// 病人信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BaseTabItem_MouseUp(object sender, MouseButtonEventArgs e)
        {
            WinPatientInfo win = new WinPatientInfo();
            win.ShowDialog();
        }
        //系统维护切换
        private void tabMaintenance_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tabMaintenance.SelectedIndex != 5)
            {
                mOldEnginner = tabMaintenance.SelectedIndex;
            }
            if (tabMaintenance.SelectedIndex == 6)
            {
                WinEngineer winEngineer = new WinEngineer();
                winEngineer.ShowDialog();
            }
        }

        private void itemEngineer_MouseUp(object sender, MouseButtonEventArgs e)
        {
            //tabMaintenance.SelectedIndex = mOldEnginner;
            WinEngineer winEngineer = new WinEngineer();
            if (ServiceProvider.EngineerValidate)
            {
                //winEngineer.ShowDialog();
            }
            else
            {
                winPassword winPwd = new winPassword(1);
                winPwd.ShowDialog();
                if (ServiceProvider.EngineerValidate)
                {
                    //winEngineer.ShowDialog();
                }
            }
        }

        #endregion

        #region 检测
        //启动按钮,判断能否开始检测并给出提示
        private void RunEvent(object sender, MouseButtonEventArgs e)
        {
            if (Convert.ToDouble(ServiceProvider.Monitor.DetectTemp) < 36.50) //温度达不到进行弹框提示.....
            {
                WinRunNotice win = new WinRunNotice();
                win.ShowDialog();
                return;
            }
            else
            {
                //ctrlBusy.IsBusy = true;
                if (ArmMoveControl.DoorStatus == 1)   //此处判断机器门是否关闭  1 代表没有关闭门
                {
                    WinDoorNoticeClose winD = new WinDoorNoticeClose(); //弹出 提示框  提示  警告  
                    winD.ShowDialog();
                    return;
                }
                else
                {
                    if (ServiceProvider.SelfCheckPass)//通过自检
                    {
                        if (!ServiceProvider.Monitor.IsRunning)//开始检测
                        {
                            if (ServiceProvider.Performability)//是否可以运行
                            {
                                ServiceProvider.Monitor.IsRunning = true;
                                WatchTimer.Start(); //开启时钟检测 启动 暂停状态
                                btnRun.Header = UIHelper.GetResourceText("Pause");
                                if (ServiceProvider.IsSimulate)
                                {
                                    Simulate();
                                }
                                else
                                {
                                    DetectChainHelper.DetectionOrder.GenerateCupList(ServiceProvider.WorkSheetVM); //按照实验类别 分配杯子 同一类型放一种杯子中
                                    DetectChainHelper.DetectionOrder.StatisticsReagentKit(ServiceProvider.ReagentKitVM); //统计本次实验的 试剂用量
                                    DetectChainHelper.DetectionOrder.CheckReagent(ServiceProvider.WorkSheetVM.WorkItemList, ServiceProvider.ReagentKitVM.ReagentItemList); //检查试剂量

                                    //ServiceProvider.gReactionCupList = new ObservableCollection<ReactionCup>();       //12.26 注释掉

                                    foreach (ReactionCup NewCup in DetectChainHelper.DetectionOrder.CupList)
                                    {
                                        ServiceProvider.gReactionCupList.Add(NewCup);
                                        NewCup.IsInStrip = true;

                                        CupDetectResultInformation reaction = new CupDetectResultInformation();
                                        reaction.DetectItem = NewCup.DetectItem;
                                        reaction.SampleInfoID = (int)NewCup.SampleInfoID;
                                        //  reaction.DetectResult = "12.1";
                                        ServiceProvider.Monitor.DetectResultListToady.Add(reaction);
                                    }
                                    //计算用量                             
                                    ArmMoveControl.lastSampleName = ServiceProvider.gReactionCupList[0].DetectItemModel.reagentName2;  //
                                    ArmMoveControl.lastReagentName = ServiceProvider.gReactionCupList[0].DetectItemModel.reagentName3;//
                                    //ServiceProvider.gReactionCupList = DetectChainHelper.DetectionOrder.CupList;

                                    //ServiceProvider.gReactionStripList = DetectChainHelper.DetectionOrder.StripList; 
                                    //ServiceProvider.Monitor.NeedStrips = DetectChainHelper.DetectionOrder.StripList;//用反应条计算推杯子的数量
                                    UIHelper.ShowKeyMessage(1000);
                                    //ServiceProvider.gReactionCupList.
                                }
                                DetectChainHelper.RunDetectChain();
                            }
                            else//无法运行的原因，试剂，底物，故障
                            {

                            }
                        }
                        else//暂停
                        {
                            //  ServiceProvider.Monitor.IsRunning = false;
                            if (btnRun.Header.ToString() == UIHelper.GetResourceText("Pause"))
                            {
                                btnRun.Header = UIHelper.GetResourceText("Run");
                                ArmMoveControl.IsPause = true;
                                DeliveryCupControl.IsPause = true;

                                //DeliveryCupControl.IsPause = true;
                                //AddReagent1AndSample.Pause(true);
                                //AddReagent2.Pause(true);
                                //AddSubstrate.Pause(true);
                                //IncubationBox.Pause(true);
                                //DeliveryWarehouse.Pause(true);
                                //Transportation.Pause(true);
                                //WashingTank.Pause(true);
                            }
                            else
                            {
                                btnRun.Header = UIHelper.GetResourceText("Pause");
                                ArmMoveControl.IsPause = false;
                                DeliveryCupControl.IsPause = false;
                                //AddReagent1AndSample.Pause(false);
                                //AddReagent2.Pause(false);
                                //AddSubstrate.Pause(false);
                                //IncubationBox.Pause(false);
                                //DeliveryWarehouse.Pause(false);
                                //Transportation.Pause(false);
                                //WashingTank.Pause(false);
                            }
                        }
                    }
                    else
                    {
                        UIHelper.ShowKeyMessage("PleaseSelfCheck");
                    }
                }
            }
        }


        //此方法模拟点击启动按钮开始实验操作进行
        public void SimulateClickRun()
        {
            if (Convert.ToDouble(ServiceProvider.Monitor.DetectTemp) < 36.50) //温度达不到进行弹框提示.....
            {
                WinRunNotice win = new WinRunNotice();
                win.ShowDialog();
                return;
            }
            else
            {
                //ctrlBusy.IsBusy = true;
                if (ArmMoveControl.DoorStatus == 1)   //此处判断机器门是否关闭  1 代表没有关闭门
                {
                    WinDoorNoticeClose winD = new WinDoorNoticeClose(); //弹出 提示框  提示  警告  
                    winD.ShowDialog();
                    return;
                }
                else
                {
                    //专属这个虚拟点击方法
                    Array.Clear(ServiceProvider.StandardResult, 0, ServiceProvider.StandardResult.Length);//清空检测结果数组 

                    if (ServiceProvider.SelfCheckPass)//通过自检
                    {
                        if (!ServiceProvider.Monitor.IsRunning)//开始检测
                        {
                            if (ServiceProvider.Performability)//是否可以运行
                            {
                                ServiceProvider.Monitor.IsRunning = true;
                                WatchTimer.Start(); //开启时钟检测 启动 暂停状态
                                btnRun.Header = UIHelper.GetResourceText("Pause");
                                if (ServiceProvider.IsSimulate)
                                {
                                    Simulate();
                                }
                                else
                                {
                                    DetectChainHelper.DetectionOrder.GenerateCupList(ServiceProvider.WorkSheetVM); //按照实验类别 分配杯子 同一类型放一种杯子中
                                    DetectChainHelper.DetectionOrder.StatisticsReagentKit(ServiceProvider.ReagentKitVM); //统计本次实验的 试剂用量
                                    DetectChainHelper.DetectionOrder.CheckReagent(ServiceProvider.WorkSheetVM.WorkItemList, ServiceProvider.ReagentKitVM.ReagentItemList); //检查试剂量

                                    //ServiceProvider.gReactionCupList = new ObservableCollection<ReactionCup>();       //12.26 注释掉

                                    //  DetectChainHelper.DetectionOrder.CupList[0].DetectItemModel.bloodAmount = 24;
                                    //  DetectChainHelper.DetectionOrder.CupList[0].DetectItemModel.reagentAmount1 =96;


                                    bool flagGO = true;
                                    foreach (ReactionCup NewCup in DetectChainHelper.DetectionOrder.CupList)
                                    {
                                        //if (flagGO)
                                        //{
                                        //    flagGO = false;
                                        //    NewCup.DetectItemModel.bloodAmount = 24;
                                        //    NewCup.DetectItemModel.reagentAmount1 = 96;
                                        //}

                                        ServiceProvider.gReactionCupList.Add(NewCup);
                                        NewCup.IsInStrip = true;

                                        CupDetectResultInformation reaction = new CupDetectResultInformation();
                                        reaction.DetectItem = NewCup.DetectItem;
                                        reaction.SampleInfoID = (int)NewCup.SampleInfoID;
                                        //  reaction.DetectResult = "12.1";
                                        ServiceProvider.Monitor.DetectResultListToady.Add(reaction);
                                    }
                                    //计算用量                             
                                    ArmMoveControl.lastSampleName = ServiceProvider.gReactionCupList[0].DetectItemModel.reagentName2;  //
                                    ArmMoveControl.lastReagentName = ServiceProvider.gReactionCupList[0].DetectItemModel.reagentName3;//
                                    //ServiceProvider.gReactionCupList = DetectChainHelper.DetectionOrder.CupList;

                                    //ServiceProvider.gReactionStripList = DetectChainHelper.DetectionOrder.StripList; 
                                    //ServiceProvider.Monitor.NeedStrips = DetectChainHelper.DetectionOrder.StripList;//用反应条计算推杯子的数量
                                    UIHelper.ShowKeyMessage(1000);
                                }
                                DetectChainHelper.RunDetectChain();
                            }
                            else//无法运行的原因，试剂，底物，故障
                            {

                            }
                        }
                        else//暂停
                        {
                            //  ServiceProvider.Monitor.IsRunning = false;
                            if (btnRun.Header.ToString() == UIHelper.GetResourceText("Pause"))
                            {
                                btnRun.Header = UIHelper.GetResourceText("Run");
                                ArmMoveControl.IsPause = true;
                                DeliveryCupControl.IsPause = true;

                                //DeliveryCupControl.IsPause = true;
                                //AddReagent1AndSample.Pause(true);
                                //AddReagent2.Pause(true);
                                //AddSubstrate.Pause(true);
                                //IncubationBox.Pause(true);
                                //DeliveryWarehouse.Pause(true);
                                //Transportation.Pause(true);
                                //WashingTank.Pause(true);
                            }
                            else
                            {
                                btnRun.Header = UIHelper.GetResourceText("Pause");
                                ArmMoveControl.IsPause = false;
                                DeliveryCupControl.IsPause = false;
                                //AddReagent1AndSample.Pause(false);
                                //AddReagent2.Pause(false);
                                //AddSubstrate.Pause(false);
                                //IncubationBox.Pause(false);
                                //DeliveryWarehouse.Pause(false);
                                //Transportation.Pause(false);
                                //WashingTank.Pause(false);
                            }
                        }
                    }
                    else
                    {
                        UIHelper.ShowKeyMessage("PleaseSelfCheck");
                    }
                }
            }
        }

        private void Simulate()
        {
            //btnRunDetect.IsEnabled = false;
            ServiceProvider.gReactionStripList = new ObservableCollection<ReactionStrip>();//模拟添加条
            Random random = new Random();
            bool oneTwoOne = true;
            for (int i = 0; i < 100; i++)
            {
                byte incubate = byte.Parse(random.Next(20, 40).ToString());

                ReactionStrip strip = new ReactionStrip()
                {
                    ID = i,
                    WhileIncubator = 20,
                    WhileLightReact = 7
                };
                if (oneTwoOne)
                {
                    strip.DetectionMethod = DetectionMethodEnum.ONE_STEP_METHOD;
                }
                else
                {
                    strip.DetectionMethod = DetectionMethodEnum.TWO_STEP_METHOD;
                }
                //oneTwoOne = !oneTwoOne;
                ServiceProvider.gReactionStripList.Add(strip);
            }
        }
        /// <summary>
        /// 暂停
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPause_Click(object sender, RoutedEventArgs e)
        {
            ServiceProvider.Pause = 3;
            DetectChainHelper.DetectTimer.Stop();

        }
        /// <summary>
        /// 继续
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnContinue_Click(object sender, RoutedEventArgs e)
        {
            ServiceProvider.Pause = 0;
            DetectChainHelper.DetectTimer.Start();
        }

        private void btnPauseSubstrate_Click(object sender, RoutedEventArgs e)
        {
            //AddSubstrate.IsPause = false;
        }
        #endregion

        #region 提示

        // 提示事件
        void WaitMessage_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                int messageCode = int.Parse(e.NewItems[0].ToString());
                UIHelper.ShowKeyMessage(messageCode);//提示

                Dispatcher.Invoke(new Action(() =>//提示后的界面操作
                {
                    switch (messageCode)
                    {
                        case 3002:
                            baseTab.SelectedIndex = 4;
                            break;
                        case 4000:
                            btnRun.Header = UIHelper.GetResourceText("Run");
                            break;
                    }
                }));
                ServiceProvider.WaitMessage.RemoveAt(0);
            }
        }
        #endregion

        #region 状态按钮事件

        private void ReagentPlate1State_MouseUp(object sender, MouseButtonEventArgs e)
        {
            baseTab.SelectedIndex = 4;
            Clipper.ClipperWindow.WinShowMessage.DlgResult myResult;

            myResult = Clipper.ClipperWindow.WinShowMessage.ShowDlg("test", "无内容", WinShowMessage.MsgBoxBtns.AbortRetryCancel, WinShowMessage.MsgBoxIcon.Information);
        }

        private void DiscardSolutionState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void RinseFlaskState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void WashFlaskVolume_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void SubstrateState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void RecycleState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void IncubationBoxState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void ReagentPlate2State_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void ReactionStripHouseState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void MaintainDays_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void SampleHouseInState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void SampleHouseOutState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void ClipperState_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }
        #endregion

        #region 窗口大小按钮,设置帮助关于,托盘菜单事件

        void winHead_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void ctrlBusy_Cancel(object sender, EventArgs e)
        {
            //ctrlBusy.IsBusy = false;
        }

        private void btnSetting_Click(object sender, RoutedEventArgs e)
        {
            //menu.IsOpen = true;
            //pop1.IsOpen = true;
        }

        private void btnMin_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void btnMax_Click(object sender, RoutedEventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)//还原
            {
                this.WindowState = WindowState.Normal;
            }
            else//最大化
            {
                this.WindowState = WindowState.Maximized;
            }
        }
        //关闭
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
            //this.ShowInTaskbar = false;
            //this.Visibility = System.Windows.Visibility.Hidden;
        }
        //设置
        private void Set_Click(object sender, RoutedEventArgs e)
        {
            WinSetting winSet = new WinSetting();
            winSet.ShowDialog();
        }
        //帮助
        private void Help_Click(object sender, RoutedEventArgs e)
        {

        }
        //关于
        private void About_Click(object sender, RoutedEventArgs e)
        {
            WinAbout winAbout = new WinAbout();
            winAbout.ShowDialog();
        }

        private void Show(object sender, EventArgs e)
        {
            this.Visibility = System.Windows.Visibility.Visible;
            this.ShowInTaskbar = true;
            this.Activate();
        }

        private void Close(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Shutdown();

        }

        #endregion

        private void userDetectResult_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void UserEngineer_Loaded(object sender, RoutedEventArgs e)
        {

        }

        /// <summary>
        /// 计算需要的量
        /// </summary>
        public void getAllNeedAmount()
        {

        }

        private void lblReagentPlate2State_MouseDown(object sender, MouseButtonEventArgs e)
        {
            WinNoticeCloseComputer computer = new WinNoticeCloseComputer();

            computer.ShowDialog();

        }

        private void lblSampleHouseOutState_MouseDown(object sender, MouseButtonEventArgs e)
        {
            DeliveryCupControl.CupToSensor(); //传送杯子
        }



        //读取配置文件
        public MDC3500Configer ReadConfigerFile()
        {
            string retString = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "MDC3500Configer.txt", System.Text.Encoding.Default);
            MDC3500Configer conObj = ServiceProvider.JsonToObject<MDC3500Configer>(retString);
            return conObj;
        }
    }
}